
<link rel="stylesheet" href="#{$smarty.const.APP}#/View/template/js/plugins/file/Huploadify.css" />
<script src="#{$smarty.const.APP}#/View/template/js/plugins/file/jquery.Huploadify.js"></script>

<div id="upload_file_{$addons_data['name']}"></div>

<input type="hidden" name="{$addons_data['name']}" id="{$addons_data['name']}" value="{$addons_data['value']}"/>

<div class="upload-img-box{$addons_data['name']}">
    {notempty name="$info[$addons_data['name']]"}
    <div class="upload-pre-file"><span class="upload_icon_all"></span><a target="_blank" href="{$info[$addons_data['name']]|default=''|get_file_url}">{$info[$addons_data['name']]|default=''|get_file_url}</a></div>
    {/notempty}
</div>

<script type="text/javascript">

    $("#upload_file_{$addons_data.name}").Huploadify({
        auto: true,
        height: 30,
        fileObjName: "file",
        buttonText: "上传文件",
        uploader: "{:url('File/fileUpload',array('session_id'=>session_id()))}",
        width: 120,
        removeTimeout: 1,
        fileSizeLimit:"{$addons_config['max_size']}",
        fileTypeExts: "{$addons_config['allow_postfix']}",
        onUploadComplete: uploadFile{$addons_data.name}
    });
    
    function uploadFile{$addons_data.name}(file, data){
        
        var data = $.parseJSON(data);
        
        $("#{$addons_data['name']}").val(data.id);
        
        var src = '/upload/file/' + data.path;
        
        $(".upload-img-box{$addons_data['name']}").html('<div class="upload-pre-file"><span class="upload_icon_all"></span><a target="_blank" href="'+src+'"> ' + src + ' <a></div>');
    }
    
</script>